import React, { Component, Children } from "react";
import PropTypes from "prop-types";
export default class Provider extends Component {
  getChildContext(state, props) {
    return this.store;
  }
  constructor(props, context) {
    super(props, context);
    this.store = props.store;
  }
  static childContextTypes = {
    store: PropTypes.any,
    methodA: PropTypes.func
  };
  componentWillReceiveProps(nextProps) {
    const { store } = this;
    const { store: nextStore } = nextProps;
    if (store !== nextStore) {
      console.log("接收到新的store", store, nextStore);
    }
  }
  render() {
    return Children.only(this.props.children);
  }
}
